home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.net;
-
- import java.io.DataOutputStream;
- import java.io.IOException;
- import symjava.lang.Bignum;
- import symjava.sql.SQLException;
-
- class NetBignum extends NumberField {
- Bignum _bigVal;
-
- int getType() {
- return 83;
- }
-
- void readData(ServerObject data) throws SQLException, IOException, ErrorException {
- String s = ((NetString)data).getString();
- this._bigVal = new Bignum(s);
- }
-
- void writeData(DataOutputStream os) throws IOException {
- try {
- NetString s = new NetString(this.getString());
- s.write(os);
- } catch (SQLException x) {
- throw new IOException(((Throwable)x).getMessage());
- }
- }
-
- public String getString() throws SQLException {
- return ((Field)this).isNull() ? null : this._bigVal.toString();
- }
-
- public boolean getBoolean() throws SQLException {
- if (((Field)this).isNull()) {
- return false;
- } else {
- int i = this._bigVal.intValue();
- return i != 0;
- }
- }
-
- public byte getByte() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- int i = this._bigVal.intValue();
- return (byte)i;
- }
- }
-
- public short getShort() throws SQLException {
- if (((Field)this).isNull()) {
- return 0;
- } else {
- int i = this._bigVal.intValue();
- return (short)i;
- }
- }
-
- public int getInt() throws SQLException {
- return ((Field)this).isNull() ? 0 : this._bigVal.intValue();
- }
-
- public long getLong() throws SQLException {
- return ((Field)this).isNull() ? 0L : this._bigVal.longValue();
- }
-
- public float getFloat() throws SQLException {
- return ((Field)this).isNull() ? 0.0F : this._bigVal.floatValue();
- }
-
- public double getDouble() throws SQLException {
- return ((Field)this).isNull() ? (double)0.0F : this._bigVal.doubleValue();
- }
-
- public Bignum getBignum(int scale) throws SQLException {
- return ((Field)this).isNull() ? null : new Bignum(this._bigVal, scale);
- }
-
- public void setBoolean(boolean x) throws SQLException {
- if (x) {
- this._bigVal = new Bignum(1);
- } else {
- this._bigVal = new Bignum(0);
- }
-
- super._null = false;
- }
-
- public void setByte(byte x) throws SQLException {
- this._bigVal = new Bignum(x);
- super._null = false;
- }
-
- public void setShort(short x) throws SQLException {
- this._bigVal = new Bignum(x);
- super._null = false;
- }
-
- public void setInt(int x) throws SQLException {
- this._bigVal = new Bignum(x);
- super._null = false;
- }
-
- public void setLong(long x) throws SQLException {
- this._bigVal = new Bignum(x);
- super._null = false;
- }
-
- public void setFloat(float x) throws SQLException {
- this._bigVal = new Bignum((double)x, 15);
- super._null = false;
- }
-
- public void setDouble(double x) throws SQLException {
- this._bigVal = new Bignum(x, 15);
- super._null = false;
- }
-
- public void setBignum(Bignum x) throws SQLException {
- this._bigVal = x;
- super._null = false;
- }
-
- public void setString(String x) throws SQLException {
- this._bigVal = new Bignum(x);
- super._null = false;
- }
-
- public int getSQLType() {
- return 2;
- }
-
- public Object getObject() throws SQLException {
- return new Bignum(this._bigVal);
- }
-
- public void setObject(Object obj) throws SQLException {
- this.setBignum((Bignum)obj);
- }
- }
-